package io.renren.modules.app.controller.user;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import io.renren.modules.app.entity.user.UserIntentionJobEntity;
import io.renren.modules.app.service.user.UserIntentionJobService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 *
 *
 * @author lym
 * @email 928185446qq.com
 * @date 2023-12-21 17:03:21
 */
@RestController
@RequestMapping("userIntentionJob")
public class UserIntentionJobController {
    @Autowired
    private UserIntentionJobService UserIntentionJobService;


    @GetMapping("/getJobList/{userId}")
    public R getJobList(@PathVariable("userId") Integer userId) {
        List<UserIntentionJobEntity> ycUserIntentionJobList = UserIntentionJobService.queryByUserId(userId);

        return R.ok().put("ycUserIntentionJobList", ycUserIntentionJobList);
    }

    @GetMapping("/deleteById/{id}")
    public R deleteById(@PathVariable("id") Integer id) {
        UserIntentionJobService.removeById(id);

        return R.ok();
    }
    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = UserIntentionJobService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		UserIntentionJobEntity UserIntentionJob = UserIntentionJobService.getInfoById(id);

        return R.ok().put("UserIntentionJob", UserIntentionJob);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody UserIntentionJobEntity UserIntentionJob){
        UserIntentionJob.setDeletestatus(false);
        UserIntentionJob.setAddtime(new Date());
		UserIntentionJobService.save(UserIntentionJob);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserIntentionJobEntity UserIntentionJob){
		UserIntentionJobService.updateById(UserIntentionJob);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		UserIntentionJobService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    @RequestMapping("/get/company/intention/job")
    public R getIntentionJobList (@RequestParam("titles") String titles,
                                  @RequestParam("cityId") String cityId,
                                  @RequestParam("page") Integer page,
                                  @RequestParam("limit") Integer limit,
                                  @RequestParam("area") String area,
                                  @RequestParam("trade") String trade,
                                  @RequestParam("scale") String scale,
                                  @RequestParam("age") String age) {
        return R.ok().put("list",
            UserIntentionJobService.selectCompanyFindList(titles, area, trade, scale, age, cityId, page, limit));
    }

    @RequestMapping("/get/user/intention/job")
    public R getIntentionJobUserList (@RequestParam("titles") String titles,
                                  @RequestParam("cityId") String cityId,
                                  @RequestParam("area") String area,
                                  @RequestParam("trade") String trade,
                                  @RequestParam("page") Integer page,
                                  @RequestParam("limit") Integer limit,
                                  @RequestParam("scale") String scale,
                                  @RequestParam("age") String age) {
        return R.ok().put("list",
                UserIntentionJobService.selectUserFindList(titles, area, trade, scale, age, cityId, page, limit));
    }

    @RequestMapping("/update/company/member")
    public R updateCompanyMember (@RequestParam("companyId") String companyId) {
        return R.ok().put("result", UserIntentionJobService.updateCompanyMemberPoints(companyId));
    }

    @RequestMapping("/get/recommend/list")
    public R getRecommendList (@RequestParam("area") String area,
                               @RequestParam("page") Integer page,
                               @RequestParam("limit") Integer limit,
                               @RequestParam("companyName") String companyName) {
        return R.ok().put("list", UserIntentionJobService.getRecommendList(area, companyName, page, limit));
    }
}
